<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/**
<span class='line'>  2</span>  * @fileOverview 공통 > 목록 > 페이징 처리 
<span class='line'>  3</span>  * @author qpitlove
<span class='line'>  4</span>  */</span><span class="WHIT">
<span class='line'>  5</span> </span><span class="NAME">nhn</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.nhn</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>  6</span> </span><span class="NAME">nhn.newsstand</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">nhn.newsstand</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>  7</span> </span><span class="NAME">nhn.newsstand.common</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">nhn.newsstand.common</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>  8</span> </span><span class="NAME">nhn.newsstand.common.page</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">nhn.newsstand.common.page</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>  9</span> </span><span class="NAME">nhn.newsstand.common.page.Pagination</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$Class</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 10</span> </span><span class="WHIT">	</span><span class="WHIT">
<span class='line'> 11</span> </span><span class="WHIT">	</span><span class="COMM">/** @lends nhn.newsstand.common.page.Pagination.prototype */</span><span class="WHIT">
<span class='line'> 12</span> </span><span class="WHIT">	</span><span class="NAME">PAGE_TEMPLATE</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'&lt;a href="#">{=page}&lt;/a>'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 13</span> </span><span class="WHIT">	</span><span class="WHIT">
<span class='line'> 14</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'> 15</span> 	 * nhn.newsstand.common.page.Pagination 클래스의 인스턴스를 생성한다.  
<span class='line'> 16</span> 	 * @constructs
<span class='line'> 17</span> 	 * @class 공통 > 목록 > 페이징 처리
<span class='line'> 18</span> 	 * @extends jindo.Component
<span class='line'> 19</span> 	 * @requires jindo.Pagination
<span class='line'> 20</span> 	 * @param {HTMLElement} elContainer 페이징 상위 Element
<span class='line'> 21</span> 	 * @param {Hashtable} oOptions 옵션 값
<span class='line'> 22</span> 	 * @example
<span class='line'> 23</span> &lt;xmp>
<span class='line'> 24</span> &lt;div class="paginate">
<span class='line'> 25</span> 	&lt;a href="#" class="pre">&lt;span class="blind">이전&lt;/span>&lt;/a>                              
<span class='line'> 26</span> 	&lt;a href="#" class="next">&lt;span class="blind">다음&lt;/span>&lt;/a>
<span class='line'> 27</span> &lt;/div>
<span class='line'> 28</span> 
<span class='line'> 29</span> &lt;script>
<span class='line'> 30</span> 	var contentPagination = new nhn.newsstand.common.page.Pagination($$.getSingle("div.paginate"),{
<span class='line'> 31</span> 		pageTemplate : '&lt;a href="#">{=page}&lt;/a>' //페이지번호 영역 템플릿
<span class='line'> 32</span> 	}).attach({
<span class='line'> 33</span> 		beforeMove :  function(oCustomEvent){ 
<span class='line'> 34</span> 			//oCustomEvent => jindo.pagination의 beforeMove CustomEvent와 동일
<span class='line'> 35</span> 			elContainer.scrollIntoView(true);
<span class='line'> 36</span> 		}
<span class='line'> 37</span> 	});
<span class='line'> 38</span> &lt;/script>
<span class='line'> 39</span> &lt;/xmp>
<span class='line'> 40</span> 	 */</span><span class="WHIT">	</span><span class="WHIT">
<span class='line'> 41</span> </span><span class="WHIT">	</span><span class="NAME">$init</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">elContainer</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">oOptions</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 42</span> </span><span class="WHIT">		</span><span class="NAME">oOptions</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">oOptions</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 43</span> </span><span class="WHIT">	</span><span class="WHIT">
<span class='line'> 44</span> </span><span class="WHIT">		</span><span class="NAME">this.welContainer</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$Element</span><span class="PUNC">(</span><span class="NAME">elContainer</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 45</span> </span><span class="WHIT">		</span><span class="NAME">this.PAGE_TEMPLATE</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">oOptions.pageTemplate</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">this.PAGE_TEMPLATE</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 46</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 47</span> </span><span class="WHIT">	</span><span class="WHIT">
<span class='line'> 48</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'> 49</span> 	 * jindo.Pagination Component를 생성한다.
<span class='line'> 50</span> 	 * @param {Number} pageNo 선택된 페이지 번호
<span class='line'> 51</span> 	 * @param {Number} itemPerPage 한 페이지에 보여줄 아이템 개수
<span class='line'> 52</span> 	 * @param {Number} totalCount 전체 아이템 개수
<span class='line'> 53</span> 	 * @return {jindo.Pagination} jindo.Pagination Component 인스턴스를 리턴 
<span class='line'> 54</span> 	 */</span><span class="WHIT">
<span class='line'> 55</span> </span><span class="WHIT">	</span><span class="NAME">_createPagination</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">pageNo</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">itemPerPage</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">totalCount</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 56</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">self</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 57</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">contentPagination</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">jindo.Pagination</span><span class="PUNC">(</span><span class="NAME">this.welContainer.$value</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 58</span> </span><span class="WHIT">			</span><span class="NAME">sPageTemplate</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">this.PAGE_TEMPLATE</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 59</span> </span><span class="WHIT">			</span><span class="NAME">nItem</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">totalCount</span><span class="WHIT"> </span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 60</span> </span><span class="WHIT">			</span><span class="NAME">nItemPerPage</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">itemPerPage</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="WHIT">			</span><span class="NAME">nPagePerPageList</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">10</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="WHIT">			</span><span class="NAME">nPage</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pageNo</span><span class="WHIT">
<span class='line'> 63</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 64</span> 
<span class='line'> 65</span> </span><span class="WHIT">		</span><span class="NAME">contentPagination.attach</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="WHIT">			</span><span class="NAME">beforeMove</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">oCustomEvent</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 67</span> </span><span class="WHIT">				</span><span class="NAME">oCustomEvent.stop</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 68</span> </span><span class="WHIT">				</span><span class="NAME">self.requestArticlesByPageNo</span><span class="PUNC">(</span><span class="NAME">oCustomEvent.nPage</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 69</span> </span><span class="WHIT">				</span><span class="NAME">self.fireEvent</span><span class="PUNC">(</span><span class="STRN">'beforeMove'</span><span class="PUNC">,</span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">oCustomEvent</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">oCustomEvent</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 70</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 72</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">contentPagination</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 73</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 74</span> </span><span class="WHIT">	</span><span class="WHIT">
<span class='line'> 75</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'> 76</span> 	 * 외부에 정의된 Request 객체를 이용하여 요청하고 응답에 따른 loadCallback CustomEvent에 Pagination 기능 사용하도록 함
<span class='line'> 77</span> 	 * @param {nhn.newsstand.common.page.Requester} oRequester 페이지용 컨텐츠 요청 Wrapper Requester
<span class='line'> 78</span> 	 * @see nhn.newsstand.common.page.Requester
<span class='line'> 79</span> 	 */</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT">	</span><span class="NAME">bindRequester</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">oRequester</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="WHIT">		</span><span class="NAME">this.oRequester</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">oRequester</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 82</span> </span><span class="WHIT">		</span><span class="WHIT">
<span class='line'> 83</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">self</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 84</span> </span><span class="WHIT">		</span><span class="NAME">this.oRequester.attach</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 85</span> </span><span class="WHIT">			</span><span class="NAME">loadCallback</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">oCustomEvent</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 86</span> </span><span class="WHIT">				</span><span class="NAME">self.updateHTMLElement</span><span class="PUNC">(</span><span class="NAME">oCustomEvent.result</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">oCustomEvent.param</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 87</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 88</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 89</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="WHIT">	</span><span class="WHIT">
<span class='line'> 91</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'> 92</span> 	 * 컨텐츠 데이터를 얻어올 때 페이지 번호를 파라미터에 추가하여 내부 바인딩된 Requester에 요청함  
<span class='line'> 93</span> 	 * @param {Number} pageNo 페이지 번호
<span class='line'> 94</span> 	 * @requires nhn.newsstand.common.page.Requester
<span class='line'> 95</span> 	 */</span><span class="WHIT">
<span class='line'> 96</span> </span><span class="WHIT">	</span><span class="NAME">requestArticlesByPageNo</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">pageNo</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">this.oRequester</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 98</span> </span><span class="WHIT">		</span><span class="NAME">this.oRequester.requestContents</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">page</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pageNo</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 99</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>100</span> </span><span class="WHIT">	</span><span class="WHIT">
<span class='line'>101</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>102</span> 	 * 컨텐츠 정보에서 받은 응답결과가 왔을 때 요청값에 대한 UI를 반영함
<span class='line'>103</span> 	 * &lt;br/>최초 응답 시 jindo.Pagination 컴포넌트가 없으면 생성하고 UI에 반영함 
<span class='line'>104</span> 	 * @param {Object} oResult 컨텐츠 데이터  
<span class='line'>105</span> 	 * @param {Object} oParam  요청 파라미터 객체 
<span class='line'>106</span> 	 */</span><span class="WHIT">
<span class='line'>107</span> </span><span class="WHIT">	</span><span class="NAME">updateHTMLElement</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">oResult</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">oParam</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>108</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hasTotalArticle</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">oResult.totalCnt</span><span class="WHIT">  </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>109</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">hasTotalArticle</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>110</span> </span><span class="WHIT">			</span><span class="NAME">this.welContainer.visible</span><span class="PUNC">(</span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>111</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>112</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>113</span> </span><span class="WHIT">		</span><span class="NAME">this.welContainer.visible</span><span class="PUNC">(</span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>114</span> </span><span class="WHIT">		</span><span class="WHIT">
<span class='line'>115</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">this.contentPagination</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>116</span> </span><span class="WHIT">			</span><span class="NAME">this.contentPagination</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this._createPagination</span><span class="PUNC">(</span><span class="NAME">oParam.page</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">oParam.pageSize</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">oResult.totalCnt</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>117</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>118</span> </span><span class="WHIT">		</span><span class="NAME">this.contentPagination.setItemCount</span><span class="PUNC">(</span><span class="NAME">oResult.totalCnt</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>119</span> </span><span class="WHIT">		</span><span class="NAME">this.contentPagination.movePageTo</span><span class="PUNC">(</span><span class="NAME">oParam.page</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>120</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>121</span> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">extend</span><span class="PUNC">(</span><span class="NAME">jindo.Component</span><span class="PUNC">)</span><span class="PUNC">;</span></pre></body></html>